Repository navigation
Improve BstIterator documentation and test coverage - #3630
Nassim29-del wants to merge 1 commit into
Conversation
- Remove redundant unchecked exception from the next() signature - Move the O(h) space explanation to the class Javadoc - Document null root handling and tree modification during iteration - Replace parameter reassignment with a for loop - Rename local variable next to current for clarity No change to traversal behavior.
PR SummaryUpdated the BstIterator to improve readability and documentation without altering traversal behavior. This change updates the class Javadoc to note O(h) space usage and the non-modification requirement during iteration, adds constructor Javadoc (null root represents an empty tree), refactors left-path pushing to use a for loop, renames the local variable Changes
autogenerated by presubmit.ai |
There was a problem hiding this comment.
✅ LGTM!
Review Summary
Commits Considered (1)
-
576721a: Improve BstIterator documentation and test coverage
-
Remove redundant unchecked exception from the next() signature
-
Move the O(h) space explanation to the class Javadoc
-
Document null root handling and tree modification during iteration
-
Replace parameter reassignment with a for loop
-
Rename local variable next to current for clarity
No change to traversal behavior.
Files Processed (1)
- iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java (1 hunk)
Actionable Comments (0)
Skipped Comments (6)
-
iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java [19-19]
maintainability: "Initialize pathStack at declaration."
-
iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java [11-13]
documentation: "Document O(h) space and mutation caveats."
-
iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java [21-25]
documentation: "Constructor documentation for edge-case root."
-
iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java [35-39]
enhancement: "Use for-loop for left spine traversal."
-
iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java [58-65]
readability: "Rename local variable in next() for clarity."
-
iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java [52-56]
documentation: "Method Javadoc consistency for unchecked exception."
What this PR does
This PR makes small readability and documentation improvements to
BstIterator. It does not change the traversal behavior.Main changes
throws NoSuchElementExceptionfrom thenext()signature, since it is an unchecked exception. It is still documented with@throws.pushPathToNextSmallestwith aforloop.nexttocurrentto avoid confusion with thenext()method.Verification
Ran
./mvnw -pl iterator -am verify, and the build passed.